<template>
	<view class="pages">
		<view class="title">
			{{DetalisData.title}}
		</view>
		<view class="date">
			{{DetalisData.updateTime || ''}}
		</view>
		<div class="content" v-html="DetalisData.content">

		</div>
		<u-button type="primary" :text="getFileExtension(DetalisData.title,DetalisData.pdfFileName)"
			:customStyle="{width:'640rpx',height:'80rpx',backgroundColor:'#273562',color:'#fff',margin:'30px auto 30rpx',fontWeight:'700',border:'none',borderRadius: '16rpx'}"
			@click="$daoChu(DetalisData.pdfFile)"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				DetalisData: {}
			}
		},
		onLoad(options) {
			this.getList(options.id)
		},
		methods: {

			getFileExtension(title, fileName) {
				if (!fileName) {
					return ""; // 如果fileName不存在或为null，则返回空字符串
				}
				var lastDotIndex = fileName.lastIndexOf(".");
				if (lastDotIndex === -1) {
					return ""; // 如果没有点号，则返回空字符串
				}
				var extension = fileName.slice(lastDotIndex);
				return title + extension;
			},
			// 获取数据
			async getList(id) {
				debugger
				uni.showLoading({
					title: this.$t('Laoding'),
				})
				const res = await this.$get(`/biz/app/libraryDetail`, {
					id: id,
				}, 0)
				this.DetalisData = res.data.data
			}
		}
	}
</script>

<style scoped>
	.pages {
		width: 100%;
		height: 100%;
		padding: 30rpx 24rpx 60rpx;
		box-sizing: border-box;
	}

	.title {
		text-align: center;
		font-size: 40rpx;
		font-weight: 900;
	}

	.content {
		width: 100%;
		margin-top: 40rpx;
		box-sizing: border-box;
	}

	.date {
		width: 100%;
		height: 20rpx;
		margin-top: 30rpx;
		text-align: center;
	}
</style>